package cn.wolfcode.luowowo.search.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import lombok.Data;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

/**
 * @author 猫教授
 * @date 2019/8/18 11:49
 */
@Data
public class SearchQueryObject extends QueryObject {
    //条件类型
    public static final int CONDITION_TYPE_ABROAD = 0;  //国外
    public static final int CONDITION_TYPE_UN_ABROAD = 1; //国内
    public static final int CONDITION_TYPE_THEME= 2; //主题



    private  String orderBy = "viewnum";  //排序

    private int type = -1;   //条件类别 : 省份id  国家id 主题id    // 关键字搜索时候用于区分不同类别
    private int typeValue = -1; //条件值

    private Long destId = -1L;   //目的地id


    public Pageable getPageable(){
        PageRequest of = PageRequest.of(super.getCurrentPage() - 1, super.getPageSize(), Sort.Direction.DESC, orderBy);
        return  of;
    }
    public Pageable getPageableWithoutSort(){
        PageRequest of = PageRequest.of(super.getCurrentPage() - 1, super.getPageSize());
        return  of;
    }
}
